/**
 *
 * @param {Object} fontInfo_obj
 * @param {Function} cb
 */
export function storeFontInfo(fontInfo_obj, cb) {
  chrome.storage.local.set(
    {
      fontinfo: fontInfo_obj,
    },
    cb
  );
}
/**
 *
 * @param {(items: { [key: string]: any }) => void} cb
 */
export function getStoredFontInfo(cb) {
  const default_font = {
    name: "UKIJ Tuz Kitab",
    ttf: "fonts/UKIJTuzKitab_Regular/UKIJTuzKitab_Regular.ttf",
    woff2: "fonts/UKIJTuzKitab_Regular/UKIJTuzKitab_Regular.woff2",
    nameing_table: {
      fontFamily: {
        en: "UKIJ Tuz Kitab",
      },
      fontSubfamily: {
        en: "Regular",
      },
      fullName: {
        en: "UKIJ Tuz Kitab",
      },
      postScriptName: {
        en: "UKIJTuzKitab",
      },
    },
  };
  return chrome.storage.local.get(
    {
      fontinfo: default_font,
    },
    cb
  );
}

export function storeBorderStatus(border_status, cb) {
  chrome.storage.local.set(
    {
      border_status,
    },
    cb
  );
}
/**
 *
 * @param {Function} cb
 */
export function getBorderStatus(cb) {
  const default_font = true;
  return chrome.storage.local.get(
    {
      border_status: default_font,
    },
    cb
  );
}

export function storeUpdateInfo(update_info, cb) {
  chrome.storage.local.set(
    {
      update_info,
    },
    cb
  );
}
/**
 *
 * @param {Function} cb
 */
export function getUpdateInfo(cb) {
  // data:{
  //   "version": {
  //     "cur": "008",
  //     "pre": "007"
  //   },
  //   "date": {
  //     "now": "当前时间",
  //     "last": "过期时间",
  //     "rest": "剩余时间"
  //   },
  //   "update": {
  //     "message": "更新通知信息",
  //     "downloadUrl": "下载地址",
  //     "moreUrl": "查看版本更新更多信息的url"
  //   }
  return chrome.storage.local.get(
    {
      update_info: {
        update: false,
        data: {},
      },
    },
    cb
  );
}
